import 'dart:io';

import 'package:flutter/material.dart';
import 'package:untitled/pages/setting.dart';
import 'package:untitled/routes/router.dart';
import 'package:untitled/pages/home_page.dart';
import 'package:untitled/pages/about.dart';
import 'package:untitled/pages/details.dart';

class BottomNavigationExample extends StatefulWidget {
  const BottomNavigationExample({super.key});

  @override
  State<BottomNavigationExample> createState() =>
      _BottomNavigationExampleState();
}

class _BottomNavigationExampleState extends State<BottomNavigationExample> {
  int _currentIndex = 0;
  final List<Widget> _pageList = [const HomePage(), const About(), Details(),Setting()];

  void _onItemTapped(int index) {
    setState(() {
      _currentIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _pageList[_currentIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(icon: Image.asset('assets/images/home.png',width: 32,height: 32,),activeIcon:Image.asset('assets/images/home-active.png',width: 32,height: 32,),label: '首页',),
          BottomNavigationBarItem(icon: Image.asset('assets/images/fen.png',width: 32,height: 32,),activeIcon:Image.asset('assets/images/fen-active.png',width: 32,height: 32,),label: '分类'),
          BottomNavigationBarItem(icon: Image.asset('assets/images/mine.png',width: 32,height: 32,),activeIcon:Image.asset('assets/images/mine-active.png',width: 32,height: 32,),label: '我的'),
          BottomNavigationBarItem(icon: Image.asset('assets/images/mine.png',width: 32,height: 32,),activeIcon:Image.asset('assets/images/mine-active.png',width: 32,height: 32,),label: '设置'),
        ],
        currentIndex: _currentIndex,
        selectedItemColor: Colors.indigoAccent,
        unselectedItemColor: Colors.black54,
        showUnselectedLabels:true,
        onTap: _onItemTapped,
      ),
    );
  }
}
